﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using XDeal.BL.Interfaces;
using XDeal.DAL.Implements;
using XDeal.DAL.Entities;
using Utility.Enums;

namespace XDeal.BL.Implements
{
    public class DealBL : IDeal
    {
        DealDAO dealDAO = new DealDAO();
        public DealBL() { }

        #region GET (Basic)
        /// <summary>
        /// Get All Deal
        /// </summary>
        /// <returns>List of Deals</returns>
        public List<Deal> GetAllDeal()
        {
            return dealDAO.GetAll();
        }

        /// <summary>
        /// Get Deal by ID
        /// </summary>
        /// <param name="ID">Deal ID</param>
        /// <returns>One Deal</returns>
        public Deal GetByID(int ID)
        {
            return dealDAO.GetByID(ID);
        }
        #endregion

        #region GET ADVANCE
        public List<Deal> GetAllDealByStatus(int currPage, int itemPerpage, ref int totalItems, DealStatus status)
        {
            return dealDAO.GetAllDealByStatus(currPage, itemPerpage, ref totalItems, status);
        }

        /// <summary>
        /// Get Valid Deal By ID. Valid = Publish | Not in Waiting for approval
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public Deal GetValidDealByID(int ID)
        {
            return dealDAO.GetValidDealByID(ID);
        }

        /// <summary>
        /// Get All List Of Deal For FrontEnd
        /// </summary>
        /// <param name="currPage">Current Page</param>
        /// <param name="itemPerpage">Item Per Page</param>
        /// <param name="totalItems">Total Items</param>
        /// <returns>List Of Deals</returns>
        public List<Deal> GetAllDealFrontEnd(int currPage, int itemPerpage, ref int totalItems)
        {
            return dealDAO.GetAllDealFrontEnd(currPage, itemPerpage, ref totalItems);
        }
        #endregion

        #region Insert, Update, Delete
        /// <summary>
        /// Insert Deal
        /// </summary>
        /// <param name="ob">Deal Object</param>
        /// <returns>True: Successful | False: Fail</returns>
        public bool Insert(Deal bo)
        {
            return dealDAO.Insert(bo);
        }

        /// <summary>
        /// Update Deal by Object
        /// </summary>
        /// <param name="ob">Deal Object</param>
        /// <returns>True: Successful | False: Fail</returns>
        public bool Update(Deal bo)
        {
            return dealDAO.Update(bo);
        }

        /// <summary>
        /// Delete Deal by Object
        /// </summary>
        /// <param name="ob">Deal Object</param>
        /// <returns>True: Successful | False: Fail</returns>
        public bool Delete(Deal bo)
        {
            return dealDAO.Delete(bo);
        }

        /// <summary>
        /// Delete By ID
        /// </summary>
        /// <param name="ID">Deal ID</param>
        /// <returns>True: Successful | False: Fail</returns>
        public bool Delete(int ID)
        {
            return dealDAO.Delete(ID);
        }
        #endregion
    }
}
